/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.proyectofinal.ramas.service;

import com.proyectofinal.ramas.domain.UserStatus;
import java.util.List;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author nicolas
 */
/**
 * Service for processing UserStatus
 *
 */
@Service("userStatusService")
@Transactional
public class UserStatusService {

    protected static Logger logger = Logger.getLogger("service");
    @Resource(name = "sessionFactory")
    private SessionFactory sessionFactory;

    /**
     * Retrieves all userStatus
     *
     * @return a list of userStatus
     */
    public List<UserStatus> getAll() {
        logger.debug("Retrieving all userStatus");

        // Retrieve session from Hibernate
        Session session = sessionFactory.getCurrentSession();

        // Create a Hibernate query (HQL)
        Query query = session.createQuery("FROM  TabUserStatus");

        // Retrieve all
        return query.list();
    }

    /**
     * Retrieves a single userStatus
     */
    public UserStatus get(Byte userStatusID) {
        // Retrieve session from Hibernate
        Session session = sessionFactory.getCurrentSession();

        // Retrieve existing userStatus first
        UserStatus userStatus = (UserStatus) session.get(UserStatus.class, userStatusID);

        return userStatus;
    }
}
